<% include "/WEB-INF/includes/cabeceira.gtpl" %>

<div id="content" class="group">

<% def erro = request.getAttribute('erro') 
%>

<% if (erro) { %>
<div class="erro">
${erro?:''}
</div>
<% } %>

<div id="container">
<div id="container-inner">

<h1>Rexistro de novo usuario</h1>
<form id="formulario"  method="post" action="/crea/rexistro">

<fieldset>
<p>introduce os teus datos</p>

<div class="campo">
<label class="etiqueta" for="nomeCompleto">Nome completo</label>
<input type="text" id="nomeCompleto" name="nomeCompleto"/>
<span class="mensaje"></span>
</div>


<div class="campo">
<label class="etiqueta" for="usuario">Nome usuario</label>
<input type="text" id="usuario" name="usuario"/>
<span class="mensaje"></span>
</div>

<div class="campo">
<label class="etiqueta" for="contrasinal">Contrasinal</label>
 <input type="password" id="contrasinal" name="contrasinal">
<span class="mensaje"></span>
</div>

<div class="campo">
<label class="etiqueta" for="confirm">Confirma o contrasinal</label>
 <input type="password" id="confirm" name="confirm">
<span class="mensaje"></span>
</div>


<div class="campo">
<label class="etiqueta" for="correo">Correo electrónico</label>
 <input type="text" id="correo" name="correo">
<span class="mensaje"></span>
</div>



  <div class="controls">
  
            
            
      <input id="submit" class="submit" name="submit" type="submit" 
          value="Rexístrate"/>
          
    </div>
    

</fieldset>

</form>
</div>
</div>


</div> <!-- /content -->


<% include "/WEB-INF/includes/pe.gtpl" %>



<script src="js/jquery-1.4.1.js" type="text/javascript"></script>
<script src="js/jquery.validate.js" type="text/javascript"></script>


<script type="text/javascript">
jQuery(function() {
	var validator = jQuery("#formulario").validate({
		rules: {
			usuario: "required",
			nomeCompleto: "required",
			contrasinal : "required",
			correo: {
                required:true,
                email:true
		    },
            confirm: {
                required:true,
                equalTo:"#contrasinal"
            }

		},
		messages: {
			usuario: "Este campo é requirido",
			nomeCompleto: "Este campo é requirido",
			contrasinal: "Este campo é requirido",
			correo: {
                required:"Este campo é requirido",
                email:"Non é un correo electrónico válido"
            },
            confirm: {
                required:"Este campo é requirido",
                equalTo:"Non coinciden os contrasinais"
            }

		},
		// the errorPlacement has to take the table layout into account
		errorPlacement: function(error, element) {
			if ( element.is(":radio") )
				error.appendTo( element.parent().next().next() );
			else if ( element.is(":checkbox") )
				error.appendTo ( element.next() );
			else
				//error.appendTo( element.parent().next() );
				error.appendTo( element.next());
		},
		
		// set this class to error-labels to indicate valid fields
		success: function(label) {
			// set &nbsp; as text for IE
			label.html("&nbsp;").addClass("checked");
		}
	});
	
});	
	
	
</script>	


<% include "/WEB-INF/includes/fin.gtpl" %>

